package wci.intermediate.symtabimpl;

import java.util.ArrayList;
import java.util.HashMap;

import wci.intermediate.*;

/**
 * <h1>SymTabEntryImpl</h1>
 *
 * <p>表项实现</p>
 *
 * <p>Copyright (c) 2009 by Ronald Mak</p>
 * <p>For instructional purposes only.  No warranties.</p>
 */
public class SymTabEntryImpl
    extends HashMap<SymTabKey, Object>
    implements SymTabEntry
{
	private static final long serialVersionUID = 3923971575610060381L;
	private String name;                     // 名称
    private SymTab symTab;                   // 所在表
    private ArrayList<Integer> lineNumbers;  // 所有出现的行位置

    public SymTabEntryImpl(String name, SymTab symTab)
    {
        this.name = name;
        this.symTab = symTab;
        this.lineNumbers = new ArrayList<Integer>();
    }

    public String getName()
    {
        return name;
    }

    public SymTab getSymTab()
    {
        return symTab;
    }
    public void appendLineNumber(int lineNumber)
    {
        lineNumbers.add(lineNumber);
    }
    public ArrayList<Integer> getLineNumbers()
    {
        return lineNumbers;
    }
    public void setAttribute(SymTabKey key, Object value)
    {
        put(key, value);
    }
    public Object getAttribute(SymTabKey key)
    {
        return get(key);
    }
}
